<?php
namespace Plu\Library\Models\Platform\Reports;

use Phalcon\Mvc\Model,
	Phalcon\Db\Column;

class ReportPlayTime extends Model {

    public function initialize() {
        $this->setConnectionService('db.platform.slave');
    }

    public function getSource() {
        return "ReportPlayTime";
    }

    static public function getPlayHourDay($RoomId, $BeginTime, $EndTime) {
        if (empty($RoomId)) {
            return false;
        }

        $item = self::find(array(
            "RoomId = :RoomId: AND EndTime >= :BeginTime: AND EndTime <= :EndTime:",
            "bind" => array(
                'RoomId' => $RoomId,
                'BeginTime' => $BeginTime,
                'EndTime' => $EndTime
            )
        ));

        if ($item == false) {
            return [];
        } else {
            return $item->toArray();
        }

    }


}


?>
